package com.tdkj.service.user.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.tdkj.dao.user.IBeanUserLevelDao;
import com.tdkj.model.user.BeanUser;
import com.tdkj.model.user.BeanUserLevel;
import com.tdkj.service.BaseService;
import com.tdkj.service.user.IBeanUserLevelService;

@Component("userLevelService")
public class BeanUserLevelServiceImpl extends BaseService  implements IBeanUserLevelService{
	private  IBeanUserLevelDao beanUserLevelDao;
	         
	@Resource
	public void setBeanUserLevelDao(IBeanUserLevelDao beanUserLevelDao) {
		this.beanUserLevelDao = beanUserLevelDao;
	}

	@Override
	public void updateUser(Long userId) {
		BeanUser user = beanUserLevelDao.findById(userId, BeanUser.class);
		String hql = " from " + BeanUserLevel.class.getName() + " as bean where bean.startnumber<='"+user.getExperience()+"' and bean.endnumber>='"+user.getExperience()+"'";
		BeanUserLevel level = (BeanUserLevel)beanUserLevelDao.getSession().createQuery(hql).uniqueResult();
		user.setUserLevel(level);
	}
	
}
